/* Public soft clock implementation */

/* Copyright (C) 2009 David Zanetti
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; version 2 of the License.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#define RTC_H

volatile uint16_t rtc_epoch; /* increments every 32-bit seconds */
volatile uint32_t rtc_s;
volatile uint32_t rtc_s_pps;
volatile uint16_t rtc_ms_pps;
volatile uint32_t rtc_s_gps;
volatile uint16_t rtc_ms_gps;
volatile uint32_t rtc_update_s;
volatile uint16_t rtc_update_ms;

/* GPS only reports time up to 1/100th of a second */

/* initalise the clock */
void rtc_init(void);

/* calibrate the clock from the GPS PPS */
void clock_calibrate(void);

/* process the now provided GPS data and soft clock data to adjust clock */
void clock_align(void);

